/**登录控制器**/
routerApp.controller('loginController', ['$scope', '$http', 'localStorageService', function ($scope, $http, localStorageService) {
        //$scope.encrypted = encrypted;
        $scope.checked = false;//默认不选中
        var ic = localStorageService.get('adminchecked');
        if (ic != null) {
            $scope.checked = ic;
        }
    	//$scope.username = localStorageService.get('username');
//      $scope.password = localStorageService.get('password');

        $scope.isCheaked = function () {
            return $scope.checked;
        };
		

        $scope.loginForm = function () {
            $scope.show = false;
            var usn=angular.element("#username").val();
            var paw=angular.element("#userpwd").val();
            var validateCode=angular.element("#code").val();
            if(usn==null||usn==""){
            	$("#error").text("请输入用户名")
            }else if(paw==null||paw==""){
            	$("#error").text("请输入密码")
            }else{
            	var password= hex_md5($scope.password);
            var formData = {
            	username:$scope.username, 
            	password:password,
            	validateCode:validateCode
            };
            $http.post('/api/admin/login', formData).success(function (resp) {
                if (resp.success) {
                    data = resp.data.data;
                    if(data!=null){
//                  	sessionStorage.setItem("token", data.id);
                    	localStorageService.set("username", data.username);
                    	localStorageService.set('type', data.type);
                    	localStorageService.set('uid', data.id);
                    	localStorageService.set('nickname', data.nickname);
                    	localStorageService.set('authOrity', data.authOrity);
                    	localStorageService.set('userlevel', data.userLevel);
                    	localStorageService.set('userOfficeAbbr', data.officeAbbr);
                    	var ck = angular.element("#icheakbox");
                    	if(ck[0].checked) {
                    		localStorageService.set('adminchecked', true);
                    		localStorageService.set('username', data.username);
                    	} else {
                    		localStorageService.set('adminchecked', false);
//                  		localStorageService.set('username', null);
//                  		localStorageService.set('password', null);
                    	}
                    	window.location.href = "/view/index/index.html";
                    }else{
                    	$("#error").text(resp.data.message);
                    }
                } else {
                    $("#error").text(resp.message)
                }
            });
           }
        };
        //回车事件
        $('#userpwd').bind('keypress', function(event) {
        	if (event.keyCode == "13") {            
            	event.preventDefault(); 
            	//回车执行查询
            	$scope.loginForm();
        	}
		});
		$('#userpwd').on('input',function(){
    		$("#error").text("")
		})
}]);
//修改密码controller
routerApp.controller('updatePswController', ['$scope','$http','localStorageService', '$filter','$rootScope','$location','toaster',function($scope,$http,localStorageService, $filter,$rootScope,$location,toaster) {	
		//用户权限
		$scope.userType=localStorageService.get('type');
		
		var id=localStorageService.get('uid');
		var adminname=localStorageService.get("username");
		
		var userlevel=localStorageService.get('userlevel');
		var auth=localStorageService.get('authOrity');
		var auth2="";
		$scope.admintype=localStorageService.get('type');
		
		$scope.yhglclick=function(){
			$scope.yhgl=true;
			$scope.xgmm=false;
		}
		$scope.xgmmclick=function(){
			$scope.yhgl=false;
			$scope.xgmm=true;
		}
		console.log($scope.admintype)
		if($scope.admintype=='SUPER_ADMIN'){
			$scope.authorityCodes="";
			if(userlevel==0){
				$scope.authorityCodes=auth
				var auth2=auth
				angular.element("#taxCode").val($scope.authorityCodes);
			}
			else if(userlevel==1){
				$scope.authorityCodes=auth.substring(0,3)
				var auth2=auth.substring(0,3)
				angular.element("#taxCode").val($scope.authorityCodes);
			}
			else if(userlevel==2){
				$scope.authorityCodes=auth.substring(0,5)
				var auth2=auth.substring(0,5)
				angular.element("#taxCode").val($scope.authorityCodes);
			}
			else if(userlevel==3){
				$scope.authorityCodes=auth.substring(0,7)
				var auth2=uth.substring(0,7)
				angular.element("#taxCode").val($scope.authorityCodes);
			}
			
			$scope.yhglclick();
		}else {
			$scope.xgmmclick();
		}
			
		$scope.page=1;
		$scope.pagesize=10;
		$scope.userList = function(){
			$http({ 
				method: "GET",
				url: "/api/admin/list",
				params: {
					"id":id,
					"nickname":$scope.nickname,
					"username":$scope.username,
					"authOrity":angular.element("#taxCode").val(),
					"userLevel":userlevel,
					"page":$scope.page,
					"pageSize":$scope.pagesize
				},
				dataType: "json"
			}).success(function(resp) {
				if(resp.success) {
					$scope.userslist = resp.data.listData;
					$scope.count = resp.data.totalRow;
				} else {
					console.log(resp.message)
				}
			}).error(function(list) {
				//处理错误
				console.log("获取接口信息错误")
			});
		}
		$scope.userList();
		
		//税务机关节点数操作
		$scope.zTree=function(modelType){
			$scope.modelType=modelType;
			if($scope.modelType==1){//等于1时新增
				//选择税务机关先关闭新增弹窗，否会堆栈溢出
				angular.element("#addUserModal").modal('hide');
			}else if($scope.modelType==2){
				//选择税务机关先关闭新增弹窗，否会堆栈溢出
				angular.element("#updateUserModal").modal('hide');
			}
			
    		$http.get('/api/taxAuthority/getAuthority?officeId='+auth2, "").success(function (resp) {
            	if (resp.success) {
            		$scope.datacode=resp.data
            		$scope.node=[];
            		for(var i in resp.data){
            			$scope.node.push({id:resp.data[i].id,name:resp.data[i].officeAbbr,pId:resp.data[i].pid,officeId:resp.data[i].officeId});
            		}
            		var zNodes=[];
            		var zNodes=$scope.node;
            		var setting = {
    					data: {
    						simpleData: {
    							enable: true
    						}
    					}
    				};
            		$(document).ready(function() {
    					$.fn.zTree.init($("#treeDemo"), setting, zNodes);
    				});
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
    		
    	}
    	
    	$scope.zTreeclick=function(){
    		$scope.authorityCodes="";
    		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    		var selectedNodes = treeObj.getSelectedNodes();
    		$scope.selectNode=selectedNodes[0];
    		if (selectedNodes.length > 0) {
				var level = selectedNodes[0].level;
				var ulevel=userlevel;
				if(level==0){
					angular.element("#authLevel").val(ulevel);
					angular.element("#updateAuth").val(ulevel);
				}
				else if(level==2&&userlevel==1){
					var ulevel=ulevel+level;
					angular.element("#authLevel").val(ulevel);
					angular.element("#updateAuth").val(ulevel);
				}else if(level==1){
					ulevel=ulevel+1;
					angular.element("#authLevel").val(ulevel);
					angular.element("#updateAuth").val(ulevel);
				}
				else if(level==2){
					ulevel=ulevel+1;
					angular.element("#authLevel").val(ulevel);
					angular.element("#updateAuth").val(ulevel);
				}
				if(ulevel==0){
					$scope.authorityCodes=$scope.selectNode.officeId;
					angular.element("#taxCode").val($scope.authorityCodes);
				}
				else if(ulevel==1){
					$scope.authorityCodes=$scope.selectNode.officeId.substring(0,3);
					angular.element("#taxCode").val($scope.authorityCodes);
				}
				else if(ulevel==2){
					$scope.authorityCodes=$scope.selectNode.officeId.substring(0,5);
					angular.element("#taxCode").val($scope.authorityCodes);
				}
				else if(ulevel==3){
					$scope.authorityCodes=$scope.selectNode.officeId.substring(0,7);
					angular.element("#taxCode").val($scope.authorityCodes);
				}
				
			}
    		//选择节点点击后 改变成选择的节点名字
    		angular.element("#authority").text($scope.selectNode.name);
    		angular.element("#authority2").text($scope.selectNode.name);
    		angular.element("#updateAuthority").text($scope.selectNode.name);
    		//隐藏弹窗
    		angular.element("#zTreeModal").modal('hide');
    		//赋值税务代码
    		angular.element("#updateOfficeId").val($scope.selectNode.officeId);
    		angular.element("#authCode").val($scope.selectNode.officeId);
    		//console.log($scope.selectNode)
    		
    		
    		
    		if($scope.modelType==1){//等于1时新增
				//选择税务机关先关闭新增弹窗，否会堆栈溢出
				angular.element("#addUserModal").modal('show');
			}else if($scope.modelType==2){
				//选择税务机关先关闭新增弹窗，否会堆栈溢出
				angular.element("#updateUserModal").modal('show');
			}
    		
    	}
		//冻结
		$scope.freeze = function (id) {
			if(window.confirm("确定冻结这个用户吗？")){
		 	var formData={
		 		id:id,
		 		state:0
		 	}
		 	$http.post('/api/admin/changeState', formData).success(function (resp) {
            	if(resp.success) {
            		
            		toaster.pop('success',"消息", "操作成功！");
            		$scope.userList();
            		
            	}else{
            		toaster.pop('error',"消息", "操作失败！");
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
        	}else{
        		
        	}
		}
		//新增
		$scope.addUser = function () {
			angular.element("#pawno").css("display","none");
			angular.element("#mimachangdu").css("display","none");
			angular.element("#mimaqiangdu").css("display","none");
			//校验两次密码输入是否一致
			var p1=angular.element("#addpaw1").val();
			var p2=angular.element("#addpaw2").val();
			if(p1==p2){
				angular.element("#pawno").css("display","none")
			}else{
				angular.element("#pawno").css("display","block")
				return;
			}
			//校验密码长度不低于6位不超过16位
			if(p1.length<6||p1.length>16){
				$("#mimachangdu").css("display","block");
				return;
			}else{
				$("#mimachangdu").css("display","none");
			}
			//校验新密码是否包含数字、字母、字符中的至少两种
			var reg=/^(?![0-9]+$)(?![a-zA-Z]+$)[A-Za-z_][A-Za-z_0-9]{0,}$/;
			if(reg.test(p1)){
				$("#mimaqiangdu").css("display","none");
			}else{
				$("#mimaqiangdu").css("display","block");
				return;
			}
			
			var pwd=hex_md5($scope.password2)
		 	var formData={
		 		adminname:adminname,
		 		nickname:$scope.nickname2,
		 		username:$scope.username2,
		 		password:pwd,
		 		authOrity:angular.element("#authCode").val(),
		 		userLevel:angular.element("#authLevel").val(),
		 		type:$scope.type
		 	}
		 	console.log(formData)
		 	$http.post('/api/admin/add', formData).success(function (resp) {
            	if(resp.success) {
            		if(resp.data.success){
//          			alert("添加成功！");
//        			$('#addUserModal').modal('hide');
            			toaster.pop('success',"消息", "操作成功！");
          				angular.element("#addUserModal").modal('hide');
            			$scope.userList();
            			window.setTimeout("window.location.reload()",2000); 
            		}else{
            			toaster.pop('error',"失败", resp.data.message);
            		}
            	}else{
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
        	
		}
		//启用
		$scope.strta = function (id) {
			if(window.confirm("确定启用吗？")){
		 	var formData={
		 		id:id,
		 		state:1
		 	}
		 	$http.post('/api/admin/changeState', formData).success(function (resp) {
            	if(resp.success) {
            		toaster.pop('success',"消息", "操作成功！");
            		$scope.userList();
            		
            	}else{
            		toaster.pop('error',"消息", "操作失败！");
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
        	}else{
        		
        	}
		}
			//退出系统 
    $scope.logout = function () {
        localStorageService.set('username', null);
        localStorageService.set('type', null);
        localStorageService.set('uid', null);
        localStorageService.set('nickname', null);
        $http.post('/api/admin/logout', "").success(function (resp) {
            	if(resp.success) {
            		if(resp.data.success){
            			
            		}else{
            			
            		}
            		
            	}else{
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        });
        
        window.location.href = "/view/index/login.html";
        
    }
		//修改密码
		$scope.save = function () {
			$("#mimaxiangtong").css("display","none");
			$("#psw2").css("display","none");
			$("#mimaqiangdu").css("display","none");
			$("#mimachangdu").css("display","none");
			//校验新旧密码是否一致
			var oldpwd=angular.element("#oldpwd").val();
			var password=angular.element("#password").val();
			if(oldpwd==password){
				$("#mimaxiangtong").css("display","block")
				return;
			}else{
				$("#mimaxiangtong").css("display","none")
			}
			//校验两次输入的新密码是否一致
			var oldpwdmd5=hex_md5(oldpwd);
			var newpwd=hex_md5($scope.pwd2);
			var newpwd2=hex_md5($scope.pwd3);
			if(newpwd==newpwd2){
				$("#psw2").css("display","none")
			}else{
				$("#psw2").css("display","block")
				return;
			}
			//校验密码长度不低于6位不超过16位
			if(password.length<6||password.length>16){
				$("#mimachangdu").css("display","block");
				return;
			}else{
				$("#mimachangdu").css("display","none");
			}
			//校验新密码是否包含数字、字母、字符中的至少两种
			var reg=/^(?![0-9]+$)(?![a-zA-Z]+$)[A-Za-z_][A-Za-z_0-9]{0,}$/;
			if(reg.test(password)){
				$("#mimaqiangdu").css("display","none");
			}else{
				$("#mimaqiangdu").css("display","block");
				return;
			}
			
		 	var formData={
		 		id:id,
		 		pwd1:oldpwdmd5,
		 		pwd2:newpwd
		 	}
		 	$http.post('/api/admin/changepwd', formData).success(function (resp) {
            	if(resp.success) {
            		if(resp.data.success){
            			toaster.pop('success',"消息", "密码修改成功！");
            			window.setTimeout("window.location.href = '/view/index/index.html'",2000); 
						
            		}else{
            			$("#yuan").text("旧密码错误")
            			toaster.pop('error',"消息", "密码修改失败！");
            		}
            		
            	}else{
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
		}
		//查询某个用户
		$scope.getUserById = function(id){
			$http({
				method: "GET",
				url: "/api/admin/getUserById",
				params: {
					"id":id
				},
				dataType: "json"
			}).success(function(resp) {
				if(resp.success) {
					angular.element("#ids").val(resp.data.id)
					angular.element("#nicknames").val(resp.data.nickname)
					angular.element("#usernames").val(resp.data.username)
					angular.element("#passwords").val(resp.data.password)
					angular.element("#types").val(resp.data.type)
					angular.element("#updateAuthority").text(resp.data.officeAbbr)
					angular.element("#updateAuth").val(resp.data.userLevel)
				} else {
					console.log(resp.message)
				}
			}).error(function(list) {
				//处理错误
				console.log("获取接口信息错误")
			});
		}
		//修改信息
		$scope.updateUser = function () {
		 	var formData={
		 		id:angular.element("#ids").val(),
		 		nickname:angular.element("#nicknames").val(),
		 		username:angular.element("#usernames").val(),
		 		type:angular.element("#types").val(),
		 		authOrity:angular.element("#updateOfficeId").val(),
		 		userLevel:angular.element("#updateAuth").val()
		 	}
		 	$http.post('/api/admin/updateUser', formData).success(function (resp) {
            	if(resp.success) {
            		
//          		alert("修改成功！")
          			toaster.pop('success',"消息", "修改成功！");
          			angular.element("#updateUserModal").modal('hide');
            		$scope.userList();
            		window.setTimeout("window.location.reload()",2000); 
          			
            	}else{
            		toaster.pop('error',"消息", "修改失败！");
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
        	
		}
		
	
		
//		$scope.yhgl=true;
		
		
		
}]);

//头部导航Controller
routerApp.controller('headController', ['$scope','$http','localStorageService','$rootScope','$interval',
	function($scope,$http,localStorageService,$rootScope,$interval) {
		 $scope.indexSZ = 1;
		$rootScope.$on('$stateChangeStart',function (event, toState, toParams, fromState, fromParams) {
            if (window.location.href.indexOf("#/index") > 0) {
                $scope.indexSZ = 1;
            }
            else if (window.location.href.indexOf("#/tax-yz") > 0) {
                $scope.indexSZ = 2;
            }
            else if (window.location.href.indexOf("#/tax-check") > 0) {
                $scope.indexSZ = 3;
            }
            else if (window.location.href.indexOf("#/tax-schedule") > 0) {
                $scope.indexSZ = 4;
            }else{
            	 
            	 $scope.indexSZ = 0;
            }
        });
        $scope.type=localStorageService.get('type');
        $scope.uid = localStorageService.get('uid');
        
		if ($scope.uid === null) {
    		// 新增非登录用户过滤
    		window.location.href = "/view/index/login.html";
		}else{
			$scope.nickname = localStorageService.get('nickname');
			$scope.userOfficeAbbr=localStorageService.get('userOfficeAbbr');
		}
		
   		//退出系统 
    $scope.logout = function () {
        localStorageService.set('username', null);
        localStorageService.set('type', null);
        localStorageService.set('uid', null);
        localStorageService.set('nickname', null);
        $http.post('/api/admin/logout', "").success(function (resp) {
            	if(resp.success) {
            		if(resp.data.success){
            			
            		}else{
            			
            		}
            		
            	}else{
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        });
        
        window.location.href = "/view/index/login.html";
        
    }
    //检测登录信息是否一致
    $scope.checkUser = function () {
            var uid=localStorageService.get('uid');
            
            $http.get('/api/admin/getUserById?id='+uid,"").success(function (resp) {
                if (resp.success) {
                    data = resp.data;
                    if(data!=null){                  	
//                  	localStorageService.set('uid', data.id);
//                  	localStorageService.set('nickname', data.nickname);
//                  	localStorageService.set('userOfficeAbbr', data.officeAbbr);
						var username=localStorageService.get("username");
                    	var type=localStorageService.get('type');
                    	var autho=localStorageService.get('authOrity');
                    	var userlevel=localStorageService.get('userlevel');
                    	if(username !=data.username || type!=data.type || autho!=data.authOrity || userlevel!=data.userLevel){
                    		alert("身份已过期，请重新登录")
                    		$scope.logout();
                    	}
                    }
                }
            });
    }
   $scope.checkUser();
    	var ic = localStorageService.get('adminchecked');
    	console.log(ic)
//		if(ic){
//			
//		} else {
//			var tok=sessionStorage.getItem("token");
//      	if(tok==null){
//      		window.location.href = "/view/index/login.html";
//      	}
//		}
  		
  		//截取税务代码放到全局
  		var auth=localStorageService.get('authOrity');
		var userlevel=localStorageService.get('userlevel');
		var auth2="";
				if(userlevel==0){
					var auth2=auth
				}
				else if(userlevel==1){
					var auth2=auth.substring(0,3)
				}
				else if(userlevel==2){
					var auth2=auth.substring(0,5)
				}
				else if(userlevel==3){
					var auth2=auth.substring(0,7)
				}
		localStorageService.set('authLevelOrity',auth2);//国税代码
		var dauth=auth2.replace(/1/,"2")
		localStorageService.set('dauth',dauth);//地税代码
		
}]);
/*主页数据统计indexController*/
routerApp.controller('indexController', ['$scope','$http','localStorageService',function($scope,$http,localStorageService) {
		var auth=localStorageService.get('authLevelOrity');
		var dauth=localStorageService.get('dauth');
		
		//顶部数据统计(当天)
     $http.get('/api/home/tdcount?taxAuthorityCode='+auth, "").success(function (resp) {
          if (resp.success) {
          		$scope.dtdate=resp.data; //当天纳税数量
          } else {
              console.log(resp.message)
          }
      }).error(function (list) {
          //处理错误
           console.log("获取接口信息错误")
      });
      
		//顶部数据统计(昨天)
     $http.get('/api/home/ydcount?taxAuthorityCode='+auth, "").success(function (resp) {
          if (resp.success) {
          		$scope.yddate=resp.data; //当天纳税数量
          } else {
              console.log(resp.message)
          }
      }).error(function (list) {
          //处理错误
           console.log("获取接口信息错误")
      });
      
		//顶部数据统计(7天平均)
//   $http.get('/api/home/avgcount?taxAuthorityCode='+auth, "").success(function (resp) {
//        if (resp.success) {
//        		$scope.qddate=resp.data; //当天纳税数量
//        } else {
//            console.log(resp.message)
//        }
//    }).error(function (list) {
//        //处理错误
//         console.log("获取接口信息错误")
//    });
      
      //顶部数据统计(当月)
     $http.get('/api/home/mcount?taxAuthorityCode='+auth, "").success(function (resp) {
          if (resp.success) {
          		$scope.mcdate=resp.data; //当天纳税数量
          } else {
              console.log(resp.message)
          }
      }).error(function (list) {
          //处理错误
           console.log("获取接口信息错误")
      });
      
      
		//top10纳税排行
        $http.get('/api/index/topten', "").success(function (resp) {
            if (resp.success) {
            	$scope.topdatas=resp.data;
            } else {
                console.log(resp.message)
            }
        }).error(function (list) {
            //处理错误
             console.log("获取接口信息错误")
        });
		
		
 var date=new Date;
 var year=date.getFullYear(); 
 var month=date.getMonth()+1;
 month =(month<10 ? "0"+month:month); 
 var mydate = (year.toString()+"-"+month.toString());

       //本月统计折线图
		 	$http({
				method: "GET",
				url: "/api/index/taxmonth",
				params: {
					"format":mydate,
					"taxAuthorityCode":auth
				},
				dataType: "json"
			}).success(function (resp) {
            if (resp.success) {
            	console.log(resp.data)
            	$scope.today = new Date();
            	$scope.cmonth = $scope.today.getMonth();
            	$scope.year =  $scope.today.getFullYear();
            	$scope.days=[];
            	var datatime=new Array();
            	var  max = new Date($scope.year,$scope.cmonth+1,0).getDate();
            	var datamoney=new Array();
                //获取本月多少天
                for(var i=1;i<=max;i++){
                		$scope.days.push({day:i}); 
                		datatime.push(parseInt(i)); 
                		datamoney.push(0);
                }
                
            	
            		for(var i in resp.data){
            			var month=parseInt(resp.data[i].mtime.substring(8));//获取的数据每天           			
            			
            			for(var a=1;a<=datatime.length;a++){
            				var monthint=parseInt(datatime[a]);//日历中的每天
            				
            				if(month==monthint){
            					datamoney[a]=(resp.data[i].money);
            				}
            			}        			
            		}
                line.setOption({
        			title: {
        				text: '本月缴税情况统计',
        				//subtext: '虚构数据',
        				left: 'center'
    				},
    				tooltip: {
        				trigger: 'item',
        				formatter: "当日纳税额 <br/>{b}号: {c} "
    				},
        			 xAxis: {
        			 	data: datatime,
        				type: 'category'
        				
    				},
    				yAxis: {
        				type: 'value'
    				},
    				series: [{
        				data: datamoney,
        				type: 'line'
    				}]
        		});
            } else {
                console.log(resp.message)  
            }
        }).error(function (list) {
            //处理错误
             console.log("获取接口信息错误")
        });
        
        
        //支付统计接口
        $http.get('/api/index/paytype?taxAuthorityCode='+auth, "").success(function (resp) {
            if (resp.success) {
            	//设置支付数量统计
               pay.setOption({
               		series: {
							type: 'pie',
							radius: '65%',
				            center: ['50%','50%'],
						data: [
						{
							name: resp.data.alipayCount == 0 ? '' : '支付宝',
							value: resp.data.alipayCount,
		                itemStyle: {                            
							color: '#57afe3'
						},
		                 labelLine: {
							normal: {
								show: resp.data.alipayCount == 0 ? false : true
							}
						}
						},
						{
							name: resp.data.wechatCount == 0 ? '' : '微信',
							value: resp.data.wechatCount,
		                		itemStyle: {
									color: '#6ee555'
								},
		                labelLine: {
							normal: {       
								show: resp.data.wechatCount == 0 ? false : true
							}
						}                            
						},
						{
							name: resp.data.sanfangCount == 0 ? '' : '网银',
							value: resp.data.sanfangCount,
		                		itemStyle: {                            
									color: '#f2bc4f'                                
								},
		                    labelLine: {                                    
								normal: {                                        
									show: resp.data.sanfangCount == 0 ? false : true                                    
								}                                
							}                            
						}]
					}
              });
            } else {
                console.log(resp.message)
            }
        }).error(function (list) {
            //处理错误
             console.log("错误")
        });
     	//征收项目统计接口
        $http.get('/api/index/payZsxm?taxAuthorityCode='+auth, "").success(function (resp) {
            if (resp.success) {
            	 var names = [];    //类别数组（用于存放饼图的类别）
    			 var brower = [];
            	console.log(resp.data)
            	$.each(resp.data, function (index, item) {
            		 names.push(item.zsxmMc);  
            		 brower.push({
                    	name: item.zsxmMc,
                    	value: item.zsxmCount
                	});
            	})
            zsxm.hideLoading();    //隐藏加载动画
            zsxm.setOption({        //加载数据图表                
                legend: {                    
                    data: names
                },
                series: [{                    
                    data: brower
                }]
            });
            }
        }).error(function (list) {
            //处理错误
             console.log("错误")
        });
 // 绘制支付统计饼图表。
       var pay= echarts.init(document.getElementById('main_pay'))
       pay.setOption({
        	title: {
        	text: '本月支付来源统计',
        	left: 'center', 
        	
    	},
    	tooltip: {
        		trigger: 'item',
        		formatter: "支付来源<br/>{b}: {c} ({d}%)"
    	},
        series: {
            type: 'pie',
            data: [
                {name: '支付宝', value: $scope.alipayCount,
                itemStyle: {
        			color: '#57afe3'
    			}},
                {name: '微信', value: $scope.wechatCount,
                itemStyle: {
        			color: '#6ee555'
    			}},
                {name: '网银', value: $scope.sanfangCount,
                itemStyle: {
        			color: '#f2bc4f'
    			}}
            ]
            }
        });
       
         // 绘制征收项目园图表。
        var zsxm= echarts.init(document.getElementById('main_yuqi'))
       	zsxm.setOption({
        color: ['#ff7d27', '#47b73d', '#fcc36e', '#57a2fd', "#228b22","#FF4500","#EEC900","#D15FEE","#9400D3","#98F5FF","#8B2323","#36648B"],//饼图颜色
        title: {
            text: '本月征收项目',
            x:'center'
        },
        tooltip: {
            trigger: 'item',
            formatter: "{a} <br/>{b} : {c} ({d}%)"
        },        
        legend: {
            orient: 'vertical',
            x: 'left',
            data: []
        },        
        toolbox: {
            show: true,
            feature: {
                mark: { show: true },
                dataView: { show: true, readOnly: false },
                magicType: {
                    show: true,
                    type: ['pie', 'funnel'],
                    option: {
                        funnel: {
                            x: '55%',
                            width: '100%',
                            funnelAlign: 'left',
                            max: 1548
                        }
                    }
                },
                restore: { show: true },
                saveAsImage: { show: true }
            }
        },         
        series: [{
            name: '征收项目',
            type: 'pie',
            radius: '58%',
            center: ['55%', '45%'],            
            data: []
        }]        
    });
        // 绘制line折线图。
         var line = echarts.init(document.getElementById('main_zhexian'));
        line.setOption({
        	title: {
        		text: '本月缴税情况统计',
        		//subtext: '虚构数据',
        		left: 'center'
    		},
    		tooltip: {
        		trigger: 'item',
        		formatter: "当日纳税额 <br/>{b}号: {c} "
    		},
        	 xAxis: {
        		type: 'category',
        		data: ['1', '2', '3', '4', '5', '6','7','8','9','10','11','12','13','14','15','16','17','18',
        				'19','20','21','22','23','24','25','26','27','28','29','30','31']
    		},
    		yAxis: {
        		type: 'value'
    		},
    		series: [{
        		data: [],
        		type: 'line'
    		}]
        });
        
        
}]);

//税务查询controller
routerApp.controller('taxyzController', ['$scope','$http','localStorageService', '$filter','$rootScope','$location',function($scope,$http,localStorageService, $filter,$rootScope,$location) {
		var auth=localStorageService.get('authOrity');
		var userlevel=localStorageService.get('userlevel');
		var userOfficeAbbr=localStorageService.get('userOfficeAbbr');
		
		var auth2="";
		angular.element("#taxCode").val(auth);
		angular.element("#authority").text(userOfficeAbbr);
		$scope.page=1;
		$scope.pagesize=10;
		$scope.taxAuthorityCode="";
				if(userlevel==0){
					$scope.taxAuthorityCode=auth
					var auth2=auth
				}
				else if(userlevel==1){
					$scope.taxAuthorityCode=auth.substring(0,3)
					var auth2=auth.substring(0,3)
				}
				else if(userlevel==2){
					$scope.taxAuthorityCode=auth.substring(0,5)
					var auth2=auth.substring(0,5)
				}
				else if(userlevel==3){
					$scope.taxAuthorityCode=auth.substring(0,7)
					var auth2=auth.substring(0,7)
				}
		//税务查询统计
		 $scope.jscxtj = function () {
		 	var s=angular.element("#startTime").val();
		 	var e=angular.element("#endTime").val();
		 	if(e!=""){
		 		e=e+" 23:59:59"
		 	}
		 	$http({
				method:"GET",
				url:"/api/transaction/getJscxtj",
				params:{
					"startTime":s,
		 			"endTime":e,
		 			"nsrsbh":$scope.nsrsbh,
		 			"taxRecepitCode":$scope.taxRecepitCode,
		 			"nsrname":$scope.nsrname,
		 			"taxStatus":$scope.taxStatus,
		 			"taxAuthorityCode":$scope.taxAuthorityCode,
		 			"payPlatformId":$scope.payPlatformId,
		 			"payWayEn":$scope.payWayEn,
		 			"schedule":$scope.schedule,
		 			"payState":$scope.payState,
		 			"page":$scope.page,
		 			"pageSize":$scope.pagesize
				},
				dataType:"json"
				}).success(function (resp) {
            	if (resp.success) {
            		$scope.shuiwuData=resp.data;
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
		 }
//		 $scope.jscxtj();
		var date = new Date();
    	var year = date.getFullYear() + "";
    	var month = (date.getMonth() + 1) + "";
    	if(month<10){
    		month="0"+month;
    	}
     	var begin = year + "-" + month + "-01"
    	angular.element("#startTime").val(begin);
    	angular.element("#startTime2").val(begin);
    	var lastDateOfCurrentMonth = new Date(year,month,0); 
    	var end = year + "-" + month + "-" + lastDateOfCurrentMonth.getDate(); 
		angular.element("#endTime").val(end);
		angular.element("#endTime2").val(end);
		//税务信息列表
		$scope.nsrefresh = function () {
		 	var s=angular.element("#startTime").val();
		 	var e=angular.element("#endTime").val();
		 	if(s!=""){
		 		s=s+" 00:00:00"
		 	}
		 	if(e!=""){
		 		e=e+" 23:59:59"
		 	}
		 	
		 	$http({
				method:"GET",
				url:"/api/transaction/getjsxx",
				params:{
					"startTime":s,
		 			"endTime":e,
		 			"nsrsbh":$scope.nsrsbh,
		 			"taxRecepitCode":$scope.taxRecepitCode,
		 			"nsrname":$scope.nsrname,
		 			"taxStatus":$scope.taxStatus,
		 			"taxAuthorityCode":$scope.taxAuthorityCode,
		 			"payPlatformId":$scope.payPlatformId,
		 			"payWayEn":$scope.payWayEn,
		 			"schedule":$scope.schedule,
		 			"payState":$scope.payState,
		 			"page":$scope.page,
		 			"pageSize":$scope.pagesize
				},
				dataType:"json"
				}).success(function (resp) {
            	if (resp.success) {
            		$scope.list=resp.data.listData;
            		$scope.count=resp.data.totalRow;
            		 $scope.jscxtj();
            		 
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
		 }
		$scope.page2=1;
		$scope.pagesize2=10;
		//地税查询统计
		 $scope.dscxtj = function () {
		 	var s=angular.element("#startTime2").val();
		 	var e=angular.element("#endTime2").val();
		 	if(e!=""){
		 		e=e+" 23:59:59"
		 	}
		 	//地税税务机关代码开头1改为2
		 	var sub=$scope.taxAuthorityCode;
		 	var dsdm=sub.replace("1","2");
		 	$http({
				method:"GET",
				url:"/api/transaction/dscxtj",
				params:{
					"startTime":s,
		 			"endTime":e,
		 			"nsrsbh":$scope.nsrsbh2,
		 			"taxRecepitCode":$scope.taxRecepitCode,
		 			"nsrname":$scope.nsrname2,
		 			"taxStatus":$scope.taxStatus2,
		 			"taxAuthorityCode":dsdm,
		 			"payPlatformId":$scope.payPlatformId2,
		 			"payWayEn":$scope.payWayEn2,
		 			"page":$scope.page2,
		 			"pageSize":$scope.pagesize2
				},
				dataType:"json"
				}).success(function (resp) {
            	if (resp.success) {
            		$scope.dishuiData=resp.data;
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
		 }
		//地税信息列表
		$scope.dsrefresh = function () {
		 	var s=angular.element("#startTime2").val();
		 	var e=angular.element("#endTime2").val();
		 	if(e!=""){
		 		e=e+" 23:59:59"
		 	}
		 	//地税税务机关代码开头1改为2
		 	var sub=$scope.taxAuthorityCode;
		 	var dsdm=sub.replace("1","2");
		 	$http({
				method:"GET",
				url:"/api/transaction/dsxxcx",
				params:{
					"startTime":s,
		 			"endTime":e,
		 			"nsrsbh":$scope.nsrsbh2,
		 			"taxRecepitCode":$scope.taxRecepitCode,
		 			"nsrname":$scope.nsrname2,
		 			"taxStatus":$scope.taxStatus2,
		 			"taxAuthorityCode":dsdm,
		 			"payPlatformId":$scope.payPlatformId2,
		 			"payWayEn":$scope.payWayEn2,
		 			"schedule":$scope.schedule2,
		 			"payState":$scope.payState2,
		 			"page":$scope.page2,
		 			"pageSize":$scope.pagesize2
				},
				dataType:"json"
				}).success(function (resp) {
            	if (resp.success) {
            		$scope.list2=resp.data.listData;
            		$scope.count2=resp.data.totalRow;
					$scope.dscxtj();
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
		 }
		
		 $scope.selectYzDetail = function(taxCode) {
            localStorageService.set("taxCode",taxCode);
            $location.path("/tax-yz-detail");
         }
		 $scope.selectDsDetail = function(reqmSgid) {
            localStorageService.set("dsreqmSgid",reqmSgid);
            $location.path("/tax-ds-detail");
         }
		 $scope.yz = false;
    	 $scope.ns = true;
    	 //地税 
    	$scope.dsClick = function () {
        	$scope.yz = true;
        	$scope.ns = false;
   	 	}
    	 //纳税
    	$scope.nsClick = function () {
        	$scope.yz = false;
        	$scope.ns = true;
   	 	}
    	
    	
    	$scope.zTree=function(){
    		$http.get('/api/taxAuthority/getAuthority?officeId='+auth2, "").success(function (resp) {
            	if (resp.success) {
            		$scope.datacode=resp.data
            		$scope.node=[];
            		for(var i in resp.data){
            			$scope.node.push({id:resp.data[i].id,name:resp.data[i].officeAbbr,pId:resp.data[i].pid,officeId:resp.data[i].officeId});
            		}
            		var zNodes=[];
            		var zNodes=$scope.node;
            		console.log($scope.node)
            		var setting = {
    					data: {
    						simpleData: {
    							enable: true
    						}
    					}
    				};
            		$(document).ready(function() {
    					$.fn.zTree.init($("#treeDemo"), setting, zNodes);
    				});
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
    		
    	}
    	
    	$scope.zTreeclick=function(){
    		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    		var selectedNodes = treeObj.getSelectedNodes();
    		$scope.selectNode=selectedNodes[0];
    		if (selectedNodes.length > 0) {
				var level = selectedNodes[0].level;
				var ulevel=userlevel;
				if(level==0){
				}
				else if(level==2&&userlevel==1){
					ulevel=ulevel+level;
				}
				else if(level==1){
					ulevel=ulevel+1;
				}
				else if(level==2){
					ulevel=ulevel+1;
				}
				if(ulevel==0){
					$scope.taxAuthorityCode=$scope.selectNode.officeId
				}
				else if(ulevel==1){
					$scope.taxAuthorityCode=$scope.selectNode.officeId.substring(0,3)
				}
				else if(ulevel==2){
					$scope.taxAuthorityCode=$scope.selectNode.officeId.substring(0,5)
				}
				else if(ulevel==3){
					$scope.taxAuthorityCode=$scope.selectNode.officeId.substring(0,7)
				}
			}
    		angular.element("#authority").text($scope.selectNode.name);
    		angular.element("#zTreeModal").modal('hide')
    		angular.element("#taxCode").val($scope.selectNode.officeId)
    		
    		//console.log($scope.selectNode)
    	}
}]);

//纳税信息详情controller
routerApp.controller('taxyzDetailController', ['$scope','$http','localStorageService','$rootScope','$location',
	function($scope,$http,localStorageService,$rootScope,$location) {
		var taxcode = localStorageService.get("taxCode");
		 //应征税款查询
		 $scope.yzskcx = function () {
		 	
		 	$http.get('/api/transaction/getJsDetail?taxCode='+taxcode,"").success(function (resp) {
            	if (resp.success) {
//          		$scope.yzdata=resp.data;
//          		$scope.schedule=resp.data.schedule;
            		$scope.list=resp.data;
            		$scope.count=$scope.list.length;
            		if(resp.data.length!=0){
            			$scope.schedule=resp.data[0].schedule
            		}
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
		 }
		 //查询电子缴税凭证
		  $scope.detailDzjspz= function (taxCertificate) {
		 	var code=taxCertificate;
		 	
		 	$http.get('/api/dz/getDzjspz?taxCertificate='+code,"").success(function (resp) {
            	if (resp.success) {
            		$scope.certdata=resp.data;
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
		 }
		 $scope.yzskcx();
		//入库明细跳转
		 $scope.selectRuKuDzMingxi = function(reqMsgId) {
            localStorageService.set("reqMsgId",reqMsgId);

            $location.path("/tax-store-detail");
        }
}]);
//地税信息详情controller
routerApp.controller('taxDsdetailController', ['$scope','$http','localStorageService','$rootScope','$location',
	function($scope,$http,localStorageService,$rootScope,$location) {
		var dsreqmSgid = localStorageService.get("dsreqmSgid");
		 //应征税款查询
		 $scope.dsskcx = function () {
		 	
		 	$http.get('/api/transaction/dstaxdetails?taxCode='+dsreqmSgid,"").success(function (resp) {
            	if (resp.success) {
            		$scope.yzdata=resp.data;
            		$scope.schedule=resp.data.schedule;
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
		 }
		 //查询电子缴税凭证
		  $scope.detailDzjspz= function (taxCertificate) {
		 	var code=taxCertificate;
		 	
		 	$http.get('/api/dz/getDzjspz?taxCertificate='+code,"").success(function (resp) {
            	if (resp.success) {
            		$scope.certdata=resp.data;
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
		 }
		 $scope.dsskcx();
		//入库明细跳转
		 $scope.selectRuKuDzMingxi = function(reqMsgId) {
            localStorageService.set("reqMsgId",reqMsgId);

            $location.path("/tax-store-detail");
        }
}]);
//对账controller
routerApp.controller('checkController', ['$scope','$http','localStorageService', '$filter','$rootScope','$location','$state','$stateParams',function($scope,$http,localStorageService, $filter,$rootScope,$location,$state,$stateParams) {
		var auth=localStorageService.get('authOrity');
		var userlevel=localStorageService.get('userlevel');
		var userOfficeAbbr=localStorageService.get('userOfficeAbbr');
		var auth2="";
		angular.element("#taxCode").val(auth);
		angular.element("#authority").text(userOfficeAbbr);
		$scope.page=1;
		$scope.pagesize=10;
		$scope.taxAuthorityCode="";
				if(userlevel==0){
					$scope.taxAuthorityCode=auth
					var auth2=auth
				}
				else if(userlevel==1){
					$scope.taxAuthorityCode=auth.substring(0,3)
					var auth2=auth.substring(0,3)
				}
				else if(userlevel==2){
					$scope.taxAuthorityCode=auth.substring(0,5)
					var auth2=auth.substring(0,5)
				}
				else if(userlevel==3){
					$scope.taxAuthorityCode=auth.substring(0,7)
					var auth2=auth.substring(0,7)
				}
				angular.element("#taxAuthCode").val($scope.taxAuthorityCode);
				$scope.zTree=function(){
    		$http.get('/api/taxAuthority/getAuthority?officeId='+auth2, "").success(function (resp) {
            	if (resp.success) {
            		$scope.datacode=resp.data
            		$scope.node=[];
            		for(var i in resp.data){
            			$scope.node.push({id:resp.data[i].id,name:resp.data[i].officeAbbr,pId:resp.data[i].pid,officeId:resp.data[i].officeId});
            		}
            		var zNodes=[];
            		var zNodes=$scope.node;
            		console.log($scope.node)
            		var setting = {
    					data: {
    						simpleData: {
    							enable: true
    						}
    					}
    				};
            		$(document).ready(function() {
    					$.fn.zTree.init($("#treeDemo"), setting, zNodes);
    				});
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
    		
    	}
    	
    	$scope.zTreeclick=function(){
    		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    		var selectedNodes = treeObj.getSelectedNodes();
    		$scope.selectNode=selectedNodes[0];
    		if (selectedNodes.length > 0) {
				var level = selectedNodes[0].level;
				var ulevel=userlevel;
				if(level==0){
					
				}
				else if(level==2&&userlevel==1){
					ulevel=ulevel+level;
				}
				else if(level==1){
					ulevel=ulevel+1;
				}
				else if(level==2){
					ulevel=ulevel+1;
				}
				if(ulevel==0){
					$scope.taxAuthorityCode=$scope.selectNode.officeId
				}
				else if(ulevel==1){
					$scope.taxAuthorityCode=$scope.selectNode.officeId.substring(0,3)
				}
				else if(ulevel==2){
					$scope.taxAuthorityCode=$scope.selectNode.officeId.substring(0,5)
				}
				else if(ulevel==3){
					$scope.taxAuthorityCode=$scope.selectNode.officeId.substring(0,7)
				}
				angular.element("#taxAuthCode").val($scope.taxAuthorityCode);
			}
    		angular.element("#authority").text($scope.selectNode.name);
    		angular.element("#zTreeModal").modal('hide')
    		angular.element("#taxCode").val($scope.selectNode.officeId)
    		
    		//console.log($scope.selectNode)
    	}
		//date时间转换
		$scope.dateTime = function(s){
			if(s!=null){
				var remindTime =s;
			var str = remindTime.toString();
			str = str.replace("/-/g", "/");
			var oDate1 = new Date(str);
			return oDate1;
			}
    	}
		var date = new Date();
    	var year = date.getFullYear() + "";
    	var month = (date.getMonth() + 1) + "";
    	if(month<10){
    		month="0"+month;
    	}
     	var begin = year + "-" + month + "-01"
    	angular.element("#startTime").val(begin);
    	var lastDateOfCurrentMonth = new Date(year,month,0); 
    	var end = year + "-" + month + "-" + lastDateOfCurrentMonth.getDate(); 
		angular.element("#endTime").val(end);
		 $scope.page1=1;
		 	$scope.pagesize1=10;
		  //入库对账列表和统计
		 $scope.rukulist = function () {
		 	 
		 	var s=angular.element("#startTime").val();
		 	var e=angular.element("#endTime").val();
//		 	var startTime=$scope.dateTime(s);
//		 	var endTime=$scope.dateTime(e);
		 	
			$http({
				method:"GET",
				url:"/api/dz/rkdz",
				params:{
					"nsrsbh":$scope.nsrsbh,
		 			"startTime":s,
		 			"endTime": e,
		 			"yzskpzh":$scope.yzskpzh,
		 			"nsrname":$scope.nsrname,
		 			"taxStatus":$scope.taxStatus,
		 			"taxAuthorityCode":angular.element("#taxAuthCode").val(),
		 			"payPlatformId":$scope.payPlatformId,
		 			"payWayEn":$scope.payWayEn,
		 			"page":$scope.page1,
		 			"pageSize":$scope.pagesize1
				},
				dataType:"json"
			}).success(function (resp) {
         	if (resp.success) {
          		$scope.rklist=resp.data.listData;
          		$scope.count1=resp.data.totalRow;
          		
          	} else {
              	console.log(resp.message)
         		}
      	}).error(function (list) {
         		//处理错误
           	console.log("获取接口信息错误")
      	});
      	
//      	//统计
		 	$http({
				method:"GET",
				url:"/api/dz/rkdztj",
				params:{
					"nsrsbh":$scope.nsrsbh,
		 			"startTime":s,
		 			"endTime": e,
		 			"yzskpzh":$scope.yzskpzh,
		 			"nsrname":$scope.nsrname,
		 			"taxStatus":$scope.taxStatus,
		 			"taxAuthorityCode":angular.element("#taxAuthCode").val(),
		 			"payPlatformId":$scope.payPlatformId,
		 			"payWayEn":$scope.payWayEn
				},
				dataType:"json"
				}).success(function (resp) {
          	if (resp.success) {
          		$scope.rktjdata=resp.data;
          	} else {
              	console.log(resp.message)
         		}
      	}).error(function (list) {
        		//处理错误
           	console.log("获取接口信息错误")
     	});
		 
		 }
  	
		  
		  //纳税详情跳转
		 $scope.selectNaSuiDzDetail = function(nsrsbh) {
		 	
            localStorageService.set("nsrsbh",nsrsbh);
            var s=angular.element("#startTime").val();
		 	var e=angular.element("#endTime").val();
			$state.go('tax-check-detail',{startTime:s,endTime:e})
//          $location.path("/tax-check-detail");
        }
		 //入库明细跳转
		$scope.selectRuKuDzMingxi = function(reqMsgId) {
            localStorageService.set("reqMsgId",reqMsgId);

            $location.path("/tax-store-detail");
        }
		
		
		
    	 //纳税显示
    	$scope.nsdzClick = function () {
        	$scope.nsdz = true;
        	$scope.rkdz = false;
       	// $scope.refresh1();
   	 	}
    	 //入库
    	$scope.rkdzClick = function () {
        	$scope.nsdz = false;
        	$scope.rkdz = true;
       		$scope.rukulist()
   	 	}
    	$scope.rkdzClick();
    	//判断是否是从入库详情面包屑进入的
    	var clickId=$stateParams.initid;
    	//为1时进入入库对账页面
//		if(clickId==1){
//			
//		}else{
//			$scope.nsdzClick();
//		}
    	
}]);


//纳税对账缴纳详情列表controller
routerApp.controller('nashuiDzDetailController', ['$scope','$http','localStorageService','$rootScope','$location','$state','$stateParams',
	function($scope,$http,localStorageService,$rootScope,$location,$state,$stateParams) {
		var nsrsbh = localStorageService.get("nsrsbh");
			$scope.page=1;
		 	$scope.pagesize=10;
		 //纳税对账缴纳详情列表
		 $scope.nashuiDetail = function () {
		 	var startTime=$stateParams.startTime;
		 	var endTime=$stateParams.endTime;
		 	$http({
				method:"GET",
				url:"/api/dz/nsdzxq",
				params:{
		 			"nsrsbh":nsrsbh,
		 			"startTime":startTime,
		 			"endTime":endTime,
		 			"page":$scope.page,
		 			"pageSize":$scope.pagesize
				},
				dataType:"json"
				}).success(function (resp) {
            	if (resp.success) {
            		$scope.nslist=resp.data.listData;
            		$scope.count=resp.data.totalRow;
            		$scope.taxPayerName=resp.data.listData[0].taxPayerName;
            		$scope.taxPayerCode=resp.data.listData[0].taxPayerCode;
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取信息错误")
        	});
		 }
		 $scope.nashuiDetail()
		 
		  $scope.selectNaSuiDzMingxi = function(reqmsgid) {
            localStorageService.set("reqmsgid",reqmsgid);

            $location.path("/store-detail");
        }
		  
		
}]);



//入库对账信息详情controller
routerApp.controller('storeDetailController', ['$scope','$http','localStorageService', '$filter','$rootScope','$location','$state','$stateParams',function($scope,$http,localStorageService, $filter,$rootScope,$location,$state,$stateParams) {
	
		var reqMsgId = localStorageService.get("reqMsgId");
	
		 //入库对账缴纳详情列表
		 $scope.rukuDetail = function () {
		 	var data={
		 		reqMsgId:reqMsgId
		 	}
		 	$http.get('/api/dz/rkdzxq?reqMsgId='+reqMsgId, "").success(function (resp) {
            	if (resp.success) {
            		$scope.datark=resp.data;

          		if(resp.data.shoudAmount==resp.data.storageTax){
          			document.getElementById("shuie").className = "glyphicon glyphicon-ok ok-green"
          			document.getElementById("paymentOk").innerHTML="正常"
        			document.getElementById("paymentOk").className="ok-green"
          		}else{
          			document.getElementById("shuie").className = "glyphicon glyphicon-remove store-remove"
        			document.getElementById("paymentOk").innerHTML="异常"
        			document.getElementById("paymentOk").className="ok-red"
          		}
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
		 }
		 $scope.rukuDetail();
		 //面包屑返回入库
//		$scope.toProducer = function(){
//			$state.go('tax-check',{initid:1})
//		}
		//查询电子缴税凭证
		  $scope.detailDzjspz= function (taxCertificate) {
		 	var code=taxCertificate;
		 	$http.get('/api/dz/getDzjspz?taxCertificate='+code,"").success(function (resp) {
            	if (resp.success) {
            		$scope.certdata=resp.data;
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
		 }
}]);




//纳税对账查看明细详情controller
routerApp.controller('nashuiDzMingxiController', ['$scope','$http','localStorageService','$rootScope',
	function($scope,$http,localStorageService,$rootScope) {
		var reqmsgid = localStorageService.get("reqmsgid");
	
		 //纳税对账缴纳详情列表
		 $scope.nashuiMingxi = function () {
		 	var data={
		 		reqMsgId:reqmsgid
		 	}
		 	$http.get('/api/dz/nsdzxqdg?reqMsgId='+reqmsgid, "").success(function (resp) {
            	if (resp.success) {
            		$scope.data=resp.data;
            		//判断数据控制对号和叉号显示
            		if(resp.data.shoudAmount==resp.data.shoudAmount){
            			document.getElementById("shouda").className = "glyphicon glyphicon-ok ok-green"
            		}else{
            			document.getElementById("shouda").className = "glyphicon glyphicon-remove store-remove"
            		}
            		
            		if(resp.data.orderAmount==resp.data.paymentAmount){
            			document.getElementById("payment").className = "glyphicon glyphicon-ok ok-green"
            		}else{
            			document.getElementById("payment").className = "glyphicon glyphicon-remove store-remove"
            		}
            		
            		if(resp.data.shoudAmount-resp.data.orderAmount==resp.data.shoudAmount-resp.data.paymentAmount){
            			document.getElementById("weijiao").className = "glyphicon glyphicon-ok ok-green"
            		}else{
            			document.getElementById("weijiao").className = "glyphicon glyphicon-remove store-remove"
            		}
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
        	});
		 }
		 $scope.nashuiMingxi()
}]);


//日历点击后查询异常对账controller
routerApp.controller('dayCheckController', ['$scope','$http','localStorageService','$rootScope','$location',
	function($scope,$http,localStorageService,$rootScope,$location) {
		var auth=localStorageService.get('authLevelOrity');
  		var status = localStorageService.get("status");
		 	$scope.page1=1;
		 	$scope.pagesize1=10;
		 //入库对账列表
		 $scope.rukulist = function () {
//		 	var s=angular.element("#startTime2").val();
//		 	var e=angular.element("#endTime2").val();
//		 	var startTime=$scope.dateTime(s);
//		 	var endTime=$scope.dateTime(e);
		 
		 	
		
			var rukuTime = localStorageService.get("rukuTime");
			var starttime=rukuTime+" 00:00:00";
			var endtime=rukuTime+" 23:59:59";
			$http({
				method: "GET",
				url: "/api/index/dzyclist",
				params: {
					"yctime": rukuTime,
					"taxAuthorityCode":auth,
					"page": $scope.page1,
					"pageSize": $scope.pagesize1
				},
				dataType: "json"
			}).success(function(resp) {
				if(resp.success) {
					$scope.rklist = resp.data.listData;
					$scope.count1 = resp.data.totalRow;

				} else {
					console.log(resp.message)
				}
			}).error(function(list) {
				//处理错误
				console.log("错误")
			});

			//统计

			$http({
				method: "GET",
				url: "/api/dz/rkdztj",
				params: {
					"startTime": starttime,
					"endTime": endtime,
					"yzskpzh": $scope.yzskpzh
				},
				dataType: "json"
			}).success(function(resp) {
				if(resp.success) {
					$scope.rktjdata = resp.data;

				} else {
					console.log(resp.message)
				}
			}).error(function(list) {
				//处理错误
				console.log("错误")
			});

			}
		  $scope.rukulist()
		 //详情跳转
		 $scope.selectNaSuiDzDetail = function(nsrsbh) {
            localStorageService.set("nsrsbh",nsrsbh);
		
            $location.path("/tax-check-detail");
        }
		$scope.selectRuKuDzMingxi = function(reqMsgId) {
            localStorageService.set("reqMsgId",reqMsgId);

            $location.path("/tax-store-detail");
       }
    	 $scope.rkdz = true;
    
    	
}]);
//企业纳税跟踪controller
routerApp.controller('taxScheduleController', ['$scope','$http','localStorageService', '$filter','$rootScope','$location',function($scope,$http,localStorageService, $filter,$rootScope,$location) {
	 var auth="";
	  auth=localStorageService.get('authLevelOrity');
	 var uid=localStorageService.get('uid');
	 $scope.userlevel=localStorageService.get('userlevel');
	var selectcode="";
	$scope.zTree=function(){
    		$http.get('/api/taxAuthority/getAuthority?officeId=137', "").success(function (resp) {
            	if (resp.success) {
            		$scope.datacode=resp.data
            		$scope.node=[];
            		for(var i in resp.data){
            			$scope.node.push({id:resp.data[i].id,name:resp.data[i].officeAbbr,pId:resp.data[i].pid,officeId:resp.data[i].officeId});
            		}
            		var zNodes=[];
            		var zNodes=$scope.node;
            		console.log($scope.node)
            		var setting = {
    					data: {
    						simpleData: {
    							enable: true
    						}
    					}
    				};
            		$(document).ready(function() {
    					$.fn.zTree.init($("#treeDemo"), setting, zNodes);
    				});
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("获取接口信息错误")
        	});
    		
    	}
    	
    	$scope.zTreeclick=function(){
    		var treeObj = $.fn.zTree.getZTreeObj("treeDemo");
    		var selectedNodes = treeObj.getSelectedNodes();
    		$scope.selectNode=selectedNodes[0];
    		if (selectedNodes.length > 0) {
				var level = selectedNodes[0].level;
				 if(level==0){
					selectcode=$scope.selectNode.officeId.substring(0,3);
				}
				else if(level==1){
					selectcode=$scope.selectNode.officeId.substring(0,5);
				}
				else if(level==2){
					selectcode=$scope.selectNode.officeId.substring(0,7);
				}
			}
    		angular.element("#authority").text($scope.selectNode.name);
       		angular.element("#taxCode").val($scope.selectNode.officeId)
    		angular.element("#zTreeModal").modal('hide')
    		//console.log($scope.selectNode)
    	}
	
	
		
		 //应征税款查询
		$scope.bbtj = function () {		
			var startTime=angular.element("#startTime").val();
			var endTime=angular.element("#endTime").val();
			if(selectcode!=""){
				auth=selectcode;
			}
			if(startTime!=""&&endTime!=""){
				
				angular.element("#bbtjload").show();
				angular.element("#bbtjid").hide(); 
				
				startTime = startTime + " 00:00:00";
				endTime = endTime + " 23:59:59";
				var recUrl="/api/tax/recRpPro";
				if(auth!=137){
					recUrl="/api/tax/recRp";
				}
				
				$http({
					method: "GET",
					url: recUrl,
					params: {
						"startTime": startTime,
						"endTime": endTime,
						"taxAuthorityCode": auth
					},
					dataType: "json"
				}).success(function(resp) {
					if(resp.success) {
						$scope.list = resp.data;
						angular.element("#bbtjload").hide();
						angular.element("#bbtjid").show();
					} else {
						console.log(resp.message)
					}
				}).error(function(list) {
					//处理错误
					console.log("获取接口信息错误")
				})
			}else{
				alert("请输入查询日期")
			}
		}
		 //第五种方法
        var idTmr;
        function  getExplorer() {
            var explorer = window.navigator.userAgent ;
            //ie
            if (explorer.indexOf("MSIE") >= 0) {
                return 'ie';
            }
            //firefox
            else if (explorer.indexOf("Firefox") >= 0) {
                return 'Firefox';
            }
            //Chrome
            else if(explorer.indexOf("Chrome") >= 0){
                return 'Chrome';
            }
            //Opera
            else if(explorer.indexOf("Opera") >= 0){
                return 'Opera';
            }
            //Safari
            else if(explorer.indexOf("Safari") >= 0){
                return 'Safari';
            }
        }
        $scope.method5=function  (tableid){
            if(getExplorer()=='ie')
            {
                var curTbl = document.getElementById(tableid);
                var oXL = new ActiveXObject("Excel.Application");
                var oWB = oXL.Workbooks.Add();
                var xlsheet = oWB.Worksheets(1);
                var sel = document.body.createTextRange();
                sel.moveToElementText(curTbl);
                sel.select();
                sel.execCommand("Copy");
                xlsheet.Paste();
                oXL.Visible = true;
 
                try {
                    var fname = oXL.Application.GetSaveAsFilename("Excel.xls", "Excel Spreadsheets (*.xls), *.xls");
                } catch (e) {
                    print("Nested catch caught " + e);
                } finally {
                    oWB.SaveAs(fname);
                    oWB.Close(savechanges = false);
                    oXL.Quit();
                    oXL = null;
                    idTmr = window.setInterval("Cleanup();", 1);
                }
 
            }
            else
            {
                tableToExcel(tableid)
            }
        }
        function Cleanup() {
            window.clearInterval(idTmr);
            CollectGarbage();
        }
        var tableToExcel = (function() {
            var uri = 'data:application/vnd.ms-excel;base64,',
                    template = '<html><head><meta charset="UTF-8"></head><body><table>{table}</table></body></html>',
                    base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) },
                    format = function(s, c) {
                        return s.replace(/{(\w+)}/g,
                                function(m, p) { return c[p]; }) }
            return function(table, name) {
                if (!table.nodeType) table = document.getElementById(table)
                var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
                window.location.href = uri + base64(format(template, ctx))
            }
        })()
		//导出excel
		/*$scope.excelDownloads = function () {	
			var startTime=angular.element("#startTime").val();
			var endTime=angular.element("#endTime").val();
			if(startTime!=""&&endTime!=""){
				startTime = startTime + " 00:00:00";
				endTime = endTime + " 23:59:59";
				angular.element("#excelid").text("正在导出...");
				window.location.href="/api/tax/excelDownloads?startTime="+startTime+"&taxAuthorityCode="+auth+"&endTime="+endTime+"&id="+uid
				
				setTimeout("angular.element('#excelid').text('导出Excel');",3000);
			}else{
				alert("请输入查询日期导出!")
			}
        	
		}*/
		
		/*---------------------------年支付情况统计-----------------------------*/
		$scope.load=function(){
			var option = {
    			title : {
        			text: '支付情况统计(年)',
        			subtext: '全部'
    			},
    			tooltip : {
        			trigger: 'axis'
    			},
    			legend: {
        			data:['支付宝','微信','网银']
    			},
    			toolbox: {
        			show : true,
        			feature : {
            				dataView : {show: true, readOnly: false},
            				magicType : {show: true, type: ['line', 'bar']},
            				restore : {show: true},
            				saveAsImage : {show: true}
        			}
    			},
    			calculable : true,
    			xAxis : [
        			{
            			type : 'category',
            			data : ['1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月']
        			}
    			],
    			yAxis : [
        			{
            			type : 'value'
        			}
    			]
    			
			};

		var myChart = echarts.init(document.getElementById('qiyetongji'));
		myChart.setOption(option);
		
		 	$http({
				method: "GET",
				url: "/api/index/typesquota",
				params: {
					"nsrsbh":$scope.nsrsbh2,
					"taxAuthorityCode":auth
				},
				dataType: "json"
			}).success(function(resp) {
            	if (resp.success) {
            		var ali=new Array();
            		var weixin=new Array();
            		var wangyin=new Array();
            		var sum=new Array();
            		var arr=new Array(0,0,0,0,0,0,0,0,0,0,0,0)
            		var date=new Date;
            		var theMonth=parseInt(date.getMonth());
            		//给数组填充到当前月份,如果没有数据则填充为0
            		for(i=0;i<=theMonth;i++){
            			weixin.push(0);
            			ali.push(0);
            			wangyin.push(0);
            			sum.push(0);
            		}
            		//判断数据,并填充到相应月份
            		for(var a in resp.data){
            			var month=resp.data[a].taxtime.substring(5);
            			var monthint=parseInt(month)-1;
          				for(var index=0;index<=arr.length;index++){
                          	if(index == monthint){
								ali[index]=resp.data[a].taxAlipay
								weixin[index]=resp.data[a].taxWechat
								wangyin[index]=resp.data[a].taxSf
								sum[index]=resp.data[a].taxCount						
                          	}
                          	
                      	}
          				
          		}
//          		console.log(resp.data)
//          		console.log(arr)
//          		console.log(ali)
//          		console.log(weixin)
//          		console.log(wangyin)
            		myChart.setOption({
            			series : [
        			{
            			name:'支付宝',
            			type:'bar',
            			data:ali,
            			markPoint : {
                			data : [
                    			{type : 'max', name: '最大值'},
                    			{type : 'min', name: '最小值'}
                			]
            			},
            			itemStyle: {
        					color: '#57afe3'
    					}
        			},
        			{
            			name:'微信',
            			type:'bar',
            			data:weixin,
            			itemStyle: {
        							color: '#6ee555'
    					}
        			},
        			{
            			name:'网银',
            			type:'bar',
            			data:wangyin,
            			
            			itemStyle: {
        					color: '#f2bc4f'
    					}
       				}
    			]
        			});
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
        	
			

		}
		
	/*---------------------------月纳税统计-----------------------------*/
		 $scope.mnstjLine=function(){
			var option = {
    			
    			tooltip : {
        			trigger: 'axis'
    			},
    			legend: {
        			data:['纳税总额']
    			},
    			toolbox: {
        			show : true,
        			feature : {
            				dataView : {show: true, readOnly: false},
            				magicType : {show: true, type: ['line', 'bar']},
            				restore : {show: true},
            				saveAsImage : {show: true}
        			}
    			},
    			calculable : true
    			
			};

		var myChart = echarts.init(document.getElementById('mnstjLine'));
		myChart.setOption(option);
		
			
			var s=angular.element("#yuensMoth").val();
			
			if(s==null||s==""){
				var date=new Date;
 				var year=date.getFullYear(); 
 				var month=date.getMonth()+1;
 				month =(month<10 ? "0"+month:month); 
 				var mydate = (year.toString()+"-"+month.toString());
				s=mydate;
			}
			
		 	$http({
				method: "GET",
				url: "/api/index/taxmonth",
				params: {
					"format":s,
					"taxAuthorityCode":auth
				},
				dataType: "json"
			}).success(function(resp) {
            	if (resp.success) {
            		if(s==null||s==""){
            			$scope.today = new Date();
            			console.log("等于null:"+$scope.today )
            		}else{
            			$scope.today = new Date(s);
            			console.log(s)
            			console.log("不等于null:"+$scope.today )
            		}
            		$scope.cmonth = $scope.today.getMonth();
            		$scope.year =  $scope.today.getFullYear();
            		var yeara=$scope.year;
            		var montha=$scope.cmonth+1;
            		$scope.days=[];
            		var datatime=new Array();
            		var  max = new Date($scope.year,$scope.cmonth+1,0).getDate();
            	
                	var datamoney=new Array();
                	//获取本月多少天
                	for(var i=1;i<=max;i++){
                		$scope.days.push({day:i}); 
                		datatime.push(parseInt(i)); 
                		datamoney.push(0);
                	}
                
            		for(var i in resp.data){
            			var month=parseInt(resp.data[i].mtime.substring(8));//获取的数据每天           			
            			
            			for(var a=0;a<=datatime.length;a++){
            				var monthint=parseInt(datatime[a]);//日历中的每天
            				
            				if(month==monthint){
            					datamoney[a]=(resp.data[i].money);
            				}
            			}        			
            		}
            		myChart.setOption({
            			title : {
        						text: yeara+'-'+montha+'月支付情况统计(日)',
        						subtext: '全部'
    					},
    					xAxis : [
        					{
            					type : 'category',
            					data : datatime
        					}
    					],
    					yAxis : [
        					{
            					type : 'value'
        					}
    					],
            			series : [
        					{
            					name:'纳税总额',
            					type:'line',
            					data:datamoney,
            					markPoint : {
                					data : [
                    					{type : 'max', name: '最大值'},
                    					{type : 'min', name: '最小值'}
                					]
            					},
            				itemStyle: {
        						color: '#cf2730'
    						}
        				}
    				]	
        			});
            		
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
		}
		 /*---------------------------月用户量统计-----------------------------*/
		 $scope.usertjLine=function(){
			

		
			var s=angular.element("#yuserMoth").val();
		 	$http({
				method: "GET",
				url: "/api/index/taxusernum",
				params: {
					"format":s,
					"taxAuthorityCode":auth
				},
				dataType: "json"
			}).success(function(resp) {
            	if (resp.success) {
            	  
            	  	
            		if(s==null||s==""){
            			$scope.today = new Date();
            		}else{
            			$scope.today = new Date(s);
            		}
            		$scope.cmonth = $scope.today.getMonth();
            		$scope.year =  $scope.today.getFullYear();
            		var yeara=$scope.year;
            		var montha=$scope.cmonth+1;
            		$scope.days=[];
            		var datatime=new Array();
            		var  max = new Date($scope.year,$scope.cmonth+1,0).getDate();
            	
                	var datamoney=new Array();
                	//获取本月多少天
                	for(var i=1;i<=max;i++){
                		$scope.days.push({day:i}); 
                		datatime.push(parseInt(i)); 
                		datamoney.push(0);
                	}
                	          		
            		for(var i in resp.data){
            			var month=parseInt(resp.data[i].mtime.substring(8));//获取的数据每天           			
            			
            			for(var a=0;a<=datatime.length;a++){
            				var monthint=parseInt(datatime[a]);//日历中的每天
            				
            				if(month==monthint){
            					datamoney[a]=(resp.data[i].userNum);
            				}
            			}        			
            		}
            		myChart.setOption({
            			title : {
        						text: yeara+'-'+montha+'月用户量(日)',
        						subtext: '全部'
    						},
    					xAxis : [
        					{
            					type : 'category',
            					data : datatime
        					}
    					],
    					yAxis : [
        					{
            					type : 'value'
        					}
    					],
            			series : [
        					{
            					name:'用户量',
            					type:'bar',
            					data:datamoney,
            					markPoint : {
                					data : [
                    					{type : 'max', name: '最大值'},
                    					{type : 'min', name: '最小值'}
                					]
            					},
            				itemStyle: {
        						color: '#00CD00'
    						}
        				}
    				]	
        			});
            	  
            	} else {
                	console.log(resp.message)
           		}
        	}).error(function (list) {
           		//处理错误
             	console.log("错误")
        	});
        	
        	
        	var option = {
    			title : {
        			text: '月用户量(日)',
        			subtext: '全部'
    			},
    			tooltip : {
        			trigger: 'axis',
        			formatter: "今日用户量 <br/>{b}号: {c}个 "
    			},
    			legend: {
        			data:['用户量']
    			},
    			toolbox: {
        			show : true,
        			feature : {
            				dataView : {show: true, readOnly: false},
            				magicType : {show: true, type: ['line', 'bar']},
            				restore : {show: true},
            				saveAsImage : {show: true}
        			}
    			},
    			calculable : true
    			
			};
					
			var myChart = echarts.init(document.getElementById('usertjLine'));
			myChart.setOption(option);
		
		
		}
		 
		 
		 
		 
		$scope.nsgz = false;//纳税跟踪
    	 $scope.zftj = false;//支付统计
    	 $scope.mnstj = true;
    	 $scope.usertj = false;
		$scope.nsdzClick = function () {
        	$scope.nsgz = true;
        	$scope.zftj = false;
        	$scope.mnstj = false;
        	$scope.usertj = false;
        	
       	// $scope.refresh1();
   	 	}
    	 //纳税
    	$scope.rkdzClick = function () {
        	$scope.nsgz = false;
        	$scope.zftj = true;
        	$scope.mnstj = false;
        	$scope.usertj = false;
       		//$scope.taxMonthTj();
   	 	}
    	$scope.mnstjClick = function () {
        	$scope.nsgz = false;
        	$scope.zftj = false;
        	$scope.mnstj = true;
        	$scope.usertj = false;
       		//$scope.taxMonthTj();
   	 	}
    	$scope.usertjClick = function () {
        	$scope.nsgz = false;
        	$scope.zftj = false;
        	$scope.mnstj = false;
        	$scope.usertj = true;
       		//$scope.taxMonthTj();
   	 	}
		 $scope.selectYzDetail = function(taxCode) {
            localStorageService.set("taxCode",taxCode);

            $location.path("/tax-yz-detail");
        }
		 
}]);
//日历插件
routerApp.controller('calendarController', ['$scope','$http','localStorageService','$location','toaster',function($scope,$http,localStorageService,$location,toaster) {
			var auth=localStorageService.get('authLevelOrity');
			if($scope.index===$scope.selected){
                $scope.showme=true;
            }else{
                $scope.showme=false;
            }

            $scope.$watch('selected', function(newVal, oldVal) {

                if($scope.index===$scope.selected){
                    $scope.showme=true;
                    $scope.refreshDay();
                }else{
                    $scope.showme=false;
                }
            });
            $scope.$watch('sx', function(newVal, oldVal) {

                if($scope.index===$scope.selected){
                   if($scope.sx==1) {
                    $scope.refreshDay();}
                }else{
                    $scope.showme=false;
                }
            });

            $scope.save=function(ptPrice){
                var month=($scope.cmonth+1)>9?($scope.cmonth+1)+"":"0"+($scope.cmonth+1);
                var  ordertimeBegin=get_unix_time($scope.year+"-"+month+"-"+$scope.rday+" 12:00:00");
                var  ordertimeEnd=ordertimeBegin;

	             }

            $scope.weeks=[ '星期日' ,'星期一', '星期二', '星期三', '星期四', '星期五', '星期六' ];
            $scope.months=[ '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月' ];
                $scope.today = new Date();
            $scope.month =  $scope.months[$scope.today.getMonth()];
            $scope.cmonth = $scope.today.getMonth();
            $scope.bmonth = $scope.today.getMonth();
            $scope.cDate=$scope.today.getDate();
            $scope.year =  $scope.today.getFullYear();

            $scope.cday=0;//当前日期
            $scope.mouseove=function(day){
                $scope.cday=day;
            }
            $scope.mouseleave=function(){
                $scope.cday=0;
            }
            //刷新页面显示天数
            $scope.refreshDay=function(){
//获取天数：
                var  firstDay = new Date($scope.year,$scope.cmonth, 1 );
                var  max = new Date($scope.year,$scope.cmonth+1,0).getDate();
                //console.log(max);
                // day of the week
                var  startingDay = firstDay.getDay();
                $scope.startdays=[];
                $scope.enddays=[];
                $scope.days=[];
                for(var i=0;i<startingDay;i++){
                    $scope.startdays.push(35+i+1);
                }
                //获取当前第一个
                for(var i=1;i<=max;i++){
//              	if(parseInt(i) < 10) {
//              		var a='0'+i
//              		$scope.days.push({day:parseInt(a),minPrice:"...."});
//              	}else{
                		$scope.days.push({day:i,minPrice:"....",status:""});
//              	}
                    
                }
                var sy=35-max-startingDay;
                for(var i=1;i<=sy;i++){
                    $scope.enddays.push(35+i+startingDay);
                }
                var Data = {
                	hid:localStorageService.get('hid'),
                	year:$scope.year,
                	month:$scope.cmonth+1,
                	totalday:max
                };
                $http.get('/api/index/dzdeviant?taxAuthorityCode='+auth,"").success(function(resp){
                    if(resp.success){
                    	for(var a in resp.data){
                    		var date = new Date(resp.data[a].time); 
                      		var d=date.getDate();
                      		var sta=resp.data[a].status;
                        	for(var index in $scope.days){
                            	if(index>=0){								
									if($scope.days[index].day==d){
										$scope.days[index].status=sta;
									}														
								}
                        	}
                       }
                    }else{
                    	
                    }
					
                }).error(function(list) {
                    //处理错误
                });

            }
            $scope.refreshDay();
            //上一月
            $scope.customPrev=function(){
                var cm= $scope.cmonth-1;
                if(cm>=0){
                    $scope.cmonth=cm;
                }else{
                    $scope.cmonth=11;
                    $scope.year=$scope.year-1;
                }
                $scope.month =  $scope.months[$scope.cmonth];
                $scope.refreshDay();
            }
            //下一月
            $scope.customNext=function(){
                var cm= $scope.cmonth+1;
                if(cm>11){
                    $scope.cmonth=0;
                    $scope.year=$scope.year+1;
                }else{
                    $scope.cmonth=cm;
                }
                $scope.month =  $scope.months[$scope.cmonth];
                $scope.refreshDay();
            }
            //异常点击
          $scope.terraPolicy = function(day){
             if(day.status==2){
             	var month=$scope.cmonth+1
             	if(parseInt(month) < 10) {
              		var ymonth='0'+month;
              		
              	}else{
              		var ymonth=month
              	}
              	if(parseInt(day.day) < 10) {
              		var yday='0'+day.day;
              		
              	}else{
              		var yday=day.day
              	}
              	
             	var time=$scope.year+"-"+ymonth+"-"+yday
             	localStorageService.set("status",day.status);
             	localStorageService.set("rukuTime",time);
            	$location.path("/day-check");
             }else{
           		toaster.pop('success', day.day+"日对账", "无异常");
             }
          };

            $scope.cancel=function(){
                //ngDialog.closeAll();
            }
}
])